<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">

$(document).ready(function(){
	$("#r_phone2,#r_phone3").AutoTab().ForceNumericOnly();
});

//다음단계
function chkSms(){
	var option = {
			url: "./pere203_2Q.do",
			data : {"p_id":'${param.p_id}',"r_phone1":$("#r_phone1").val(),"r_phone2":$("#r_phone2").val(),"r_phone3":$("#r_phone3").val()},
			success : function(json){
				if("1"==json.returnType){
					//인증이 필요한 경우
					alert("인증번호가 전송되었습니다");
					$(".A2").show();
					$(".A1").hide();
				}else if("2"==json.returnType){
					//인증이 필요없이 저장하는 경우
					saveData();
				}else if("3"==json.returnType){
					//보내기 에러인경우
					alert("sms 정보를 확인해주세요");
				}
			}
	};
	$.getJson(option);
	
// 	$(".A2").show();
// 	$(".A1").hide();
}

//인증값이 같은지 확인
function chkSmsOK(){
	var option = {
			url: "./pere203_3Q.do",
			data : {"sms_chk_data":$("#sms_chk_data").val()},
			success : function(json){
				if("Y"==json.checkYN){
					//인증값이 같은 경우
					alert("인증확인");
					saveData();
				}else{
					//인증값이 틀린경우 
					alert("인증실패");
				}
			}
	};
	$.getJson(option);
	
}

function showA1(){
	$(".A2").hide();
	$(".A1").show();
}

function saveData(){
	
	var obj = {};
	obj.r_phone1=$("#r_phone1").val();
	obj.r_phone2=$("#r_phone2").val();
	obj.r_phone3=$("#r_phone3").val();
	obj.sms_chk_data=$("#sms_chk_data").val();
	
	opener.saveData(obj);
	self.close(); 
}
</script>

<form action="./pere204Q.do" method="post" name="form1" id="frmdata">
<input name="p_id" value="${param.p_id }" type="hidden"/>
<table width="350" height="150" border="0" cellspacing="3"
	cellpadding="4" bgcolor="#989898">
		<tr class="A1">
			<td bgcolor="#FFFFFF"><table width="100%" border="0"
					cellspacing="0" cellpadding="0">
					<tr>
						<td><img src="/usr/images/forget_hpfind.gif" width="344"
							height="42"></td>
					</tr>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td height="50" align="center" valign="bottom">
							<select name="r_phone1" id="r_phone1">
							<c:if test="${code1List !=null && fn:length(code1List)>0 }">
								<c:forEach var="map1" items="${code1List}" varStatus="status">
									<option value="${map1.code }">${map1.code }</option>
								</c:forEach>
							</c:if>
							</select>-<input name="r_phone2" type="text" id="r_phone2" size="4"
								maxlength="4" value="">-<input name="r_phone3"
								type="text" id="r_phone3" size="4" maxlength="4" value="">
								<a href="#" onclick="chkSms();" >
									<img src="/usr/images/forget_hpfind2.gif" width="49" height="22" align="middle"/>
								</a>
<!-- 								<input type="button" value="휴대폰인증" onclick="chkSms()"> -->
						</td>
					</tr>
				</table></td>
		</tr>

		<tr class="A2" style="display: none;">
			<td bgcolor="#FFFFFF"><table width="100%" border="0"
					cellspacing="0" cellpadding="0">
					<tr>
						<td><img src="/usr/images/forget_hpfind.gif" width="344"
							height="42"></td>
					</tr>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td height="50" align="center" valign="bottom">고객님의 휴대전화로
							인증번호가 전송 되었습니다</td>
					</tr>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="110" height="40" align="right">인증번호&nbsp;</td>
						<td width="90"><input name="sms_chk_data" type="text"
							class="inputbox" id="sms_chk_data" size="20"></td>
						<td width="5"></td>
						<td width="49" align="center">
							<a href="#" onclick="chkSmsOK();" >
								<img src="/usr/images/forget_hpfind2.gif" width="49" height="22"/>
							</a>
<!-- 							<input type="button" value="확인" onclick="chkSmsOK()"> -->
<!-- 						<input type="image" -->
<!-- 							src="/usr/images/forget_hpfind2.gif" width="49" height="22"> -->
							</td>
						<td></td>
					</tr>
				</table></td>
		</tr>
</table>




<!-- <table> -->
<!-- 	<tr class="A1"> -->
<!-- 		<td> -->
<!-- 		전화번호 -->
<!-- 		</td> -->
<!-- 		<td> -->
<!-- 			<select name="r_phone1" id="r_phone1"> -->
<%-- 			<c:if test="${code1List !=null && fn:length(code1List)>0 }"> --%>
<%-- 				<c:forEach var="map1" items="${code1List}" varStatus="status"> --%>
<%-- 					<option value="${map1.code }">${map1.code }</option> --%>
<%-- 				</c:forEach> --%>
<%-- 			</c:if> --%>
<!-- 			</select>-<input name="r_phone2" type="text" id="r_phone2" size="4" -->
<!-- 				maxlength="4" value="">-<input name="r_phone3" -->
<!-- 				type="text" id="r_phone3" size="4" maxlength="4" value=""> -->
						
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- 	<tr class="A1"> -->
<!-- 		<td colspan="2"> -->
<!-- 			<input type="button" value="휴대폰인증" onclick="chkSms()"> -->
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- 	<tr class="A2" style="display: none;"> -->
<!-- 		<td> -->
<!-- 		인증번호 -->
<!-- 		</td> -->
<!-- 		<td> -->
<!-- 			<input name="sms_chk_data" id="sms_chk_data" type="text" value=""/> -->
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- 	<tr class="A2" style="display: none;"> -->
<!-- 		<td colspan="2"> -->
<!-- 			<input type="button" value="확인" onclick="chkSmsOK()"><input type="button" onclick="showA1();" value="인증 다시요청"> -->
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- </table> -->


</form>

